package com.lagou.edu.controller;

import com.lagou.edu.pojo.Article;
import com.lagou.edu.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName: ArticleController
 * @Auther: Jerry
 * @Date: 2020/7/22 15:37
 * @Desctiption: TODO
 * @Version: 1.0
 */
@Controller
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping("/index")
    public String findAll(@RequestParam(value = "pageNo", required = false, defaultValue = "0") Integer pageNo,
                          @RequestParam(value = "pageSize", required = false, defaultValue = "2") Integer pageSize,
            ModelMap modelMap){
        Page<Article> articles = articleService.findPage(pageNo, pageSize);
        modelMap.addAttribute("articles", articles);
        return "client/index";
    }

}
